package com.dongdong.service.impl;

import com.dongdong.mapper.TbGoodsMapper;
import com.dongdong.pojo.TbGoods;
import com.dongdong.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@com.alibaba.dubbo.config.annotation.Service
public class GoodsServiceImpl implements GoodsService {

    @Autowired
    private TbGoodsMapper tbGoodsMapper;

    @Override
    public List<TbGoods> selectAll(String goodsName) {
        List<TbGoods> goods = tbGoodsMapper.selectName(goodsName);
//        List<TbGoods> goods = tbGoodsMapper.selectByExample(null);
        return goods;
    }

    @Override
    public boolean pass(Long id) {
        TbGoods tb = new TbGoods();
        tb.setId(id);
        tb.setAuditStatus("1");
        int i = tbGoodsMapper.updateByPrimaryKeySelective(tb);
        return i > 0;
    }

    @Override
    public boolean overrule(Long id) {
        TbGoods tb = new TbGoods();
        tb.setId(id);
        tb.setAuditStatus("2");
        int i = tbGoodsMapper.updateByPrimaryKeySelective(tb);
        return i > 0;
    }


    @Override
    public TbGoods selectId(Long goodsId) {
        TbGoods tbGoods = tbGoodsMapper.selectByPrimaryKey(goodsId);
        return tbGoods;
    }
}
